#include <iostream>
#include <string>
using namespace std;

class Person{
protected:
  string _name;
  string _id;
  int _age;

public:
  Person()
    :_name("LiHua"),
    _id("123123"),
    _age(20)
  {}

  Person(const char* name, const char* id, int age)
    :_name(name),
    _id(id),
    _age(age)
  {
    cout << "Person(const char* name, const char* id, int age)" << endl;
  }
  
  Person(const Person& p)
    :_name(p._name),
    _id(p._id),
    _age(p._age)
  {
    cout << "Person(const Person& p)" << endl;
  }

  Person& operator=(const Person& p){
    if(this != &p)
    {
      _name = p._name;
      _id = p._id;
      _age = p._age;
    }

    cout << "Person& operator=(const Person& p)" << endl;
    return *this;
  }

  ~Person()
  {
    cout << "~Person()" << endl;
  }

};

class Student : public Person{
  string _stuid;
public:

  Student(){}

  Student(const char* name, const char* id, int age, const char* stuid)
    :Person(name, id, age),
    _stuid(stuid)
  {
    cout << "Student(const char* name, const char* id, int age, const char* stuid)" << endl;
  }

  Student(const Student& s)
    :Person(s),
    _stuid(s._stuid)
  {
    cout << "Student(const Student& s)" << endl;
  }

  Student& operator=(const Student& s){
    if(this != &s)
    {
      //Person::operator=(s);
      *((Person*)this) = s;
      _stuid = s._stuid;
    }
    cout << "Student& operator=(const Student& s)" << endl;

    return *this;
  }

  ~Student(){
    //Person::~Person();
    cout << "~Student()" << endl;
  }

  void Print(){
    cout << _name << " ";
    cout << _id << " ";
    cout << _age << " ";
    cout << _stuid << endl;
  }
};

void Test5(){
  Student s("张三", "123456", 18, "111");
  s.Print();
  cout << endl;

  Student s1(s);
  s1.Print();
  cout << endl;
  
  s1 = s;
  cout << endl;

  //Student s2;
  //s2.Print();
}

int main(){
  Test5();
  return 0;
}
